using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class ReturnRequestMap : EntityTypeConfiguration<ReturnRequest>
    {
        public ReturnRequestMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.ReasonForReturn)
                .IsRequired();

            this.Property(t => t.RequestedAction)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("ReturnRequest");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.StoreId).HasColumnName("StoreId");
            this.Property(t => t.OrderItemId).HasColumnName("OrderItemId");
            this.Property(t => t.CustomerId).HasColumnName("CustomerId");
            this.Property(t => t.Quantity).HasColumnName("Quantity");
            this.Property(t => t.ReasonForReturn).HasColumnName("ReasonForReturn");
            this.Property(t => t.RequestedAction).HasColumnName("RequestedAction");
            this.Property(t => t.CustomerComments).HasColumnName("CustomerComments");
            this.Property(t => t.StaffNotes).HasColumnName("StaffNotes");
            this.Property(t => t.ReturnRequestStatusId).HasColumnName("ReturnRequestStatusId");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");
            this.Property(t => t.UpdatedOnUtc).HasColumnName("UpdatedOnUtc");

            // Relationships
            this.HasRequired(t => t.Customer)
                .WithMany(t => t.ReturnRequests)
                .HasForeignKey(d => d.CustomerId);

        }
    }
}
